﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Sharp.Infrastructure.WebApiClient;
using Sharp.Portal.Mvc;
using Sharp.ServiceContracts;
using Sharp.WebBooter.Areas.Demo.Models;
namespace Sharp.WebBooter.Areas.Demo.Controllers
{
    [Authorize]
    [AutomaticTemplate]
    public class DataController : SharpController
    {
        public ActionResult Index()
        {
            return View(new GroupIndexModel());
        }
        /// <summary>
        ///     分页数据
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public ActionResult GetPaged(DataTableParameter parameters)
        {
            using (var proxy = new WebApiClientServiceProxy<IEnterpriseService>())
            {
                var pageInfo = proxy.Channel.GetGroupPaged(parameters.ToPagingFeature());

                return this.Store(pageInfo );
            }
        }


        //public ActionResult Index2()
        //{
        //    if (containerId.IsNullOrEmpty())
        //    {
        //        return View(new GroupIndexModel()
        //        {
        //            ListControlId = "ListControlId2",
        //            StoreUrlAction = nameof(GetPaged2)
        //        });
        //    }
        //    return new PartialViewResult
        //    {
        //        Model = new GroupIndexModel()
        //        {
        //            StoreUrlAction = nameof(GetPaged2)
        //        },
        //        ContainerId = containerId,
        //        RenderMode = RenderMode.AddTo
        //    };
        //}
        ///// <summary>
        /////     分页数据
        ///// </summary>
        ///// <param name="parameters"></param>
        ///// <returns></returns>
        //public ActionResult GetPaged2(ExtRequestParameters parameters)
        //{
        //    using (var proxy = new WebApiClientServiceProxy<IEnterpriseService>())
        //    {
        //        var pageInfo = proxy.Channel.GetGroupPaged(parameters.ToPagingFeature());
        //        pageInfo.Data.Clear();
        //        return this.Store(pageInfo.Data, pageInfo.TotalRecords);
        //    }
        //}
    }
}